﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.IO;
using BL;

namespace StockVentas
{
    public partial class frmPruebas : Form
    {
        public frmPruebas()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DataTable tblArticulos = BL.GetDataBLL.GetArticulos();
         /*   int i = 0;
            for (i = 0; i < 10; i++)
            { 
            
            }*/
            Cursor.Current = Cursors.WaitCursor;
            foreach (DataRow row in tblArticulos.Rows)
            {
                string oldId = row["IdArticuloART"].ToString();
                string id = "0" + oldId;
                BL.ArticulosBLL.ActualizarArticulos(id, oldId);
            }
            Cursor.Current = Cursors.Arrow;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string path = Application.StartupPath;
            using (StreamWriter fileWrite = new StreamWriter(path + "\\Backup\\temp.sql"))
            {
                using (StreamReader fielRead = new StreamReader(path + "\\Backup\\db_base.sql"))
                {
                    String line;

                    while ((line = fielRead.ReadLine()) != null)
                    {
                        if (line.Contains("db_base"))
                        {
                            string newLine = line.Replace("db_base", "benja@hotmail.com");
                            fileWrite.WriteLine(newLine);
                        }
                        else
                            fileWrite.WriteLine(line);
                    }
                }
            }
        }
    }
}
